package com.nuoniu.sibanyun.controller.erp.barcode;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nuoniu.sibanyun.common.result.HttpResult;
import com.nuoniu.sibanyun.entity.dto.ErpBarcodeRuleSearchDto;
import com.nuoniu.sibanyun.entity.dto.ErpBarcodeRuleSearchMoreDto;
import com.nuoniu.sibanyun.entity.erp.barcode.ErpBarcodeRule;
import com.nuoniu.sibanyun.entity.po.VPoPurchaseOrderMain;
import com.nuoniu.sibanyun.service.erp.barcode.IErpBarcodeRuleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.nuoniu.sibanyun.common.BaseController;

/**
 * <p>
 * 条码管理-条码规则 前端控制器
 * </p>
 *
 * @author 白强
 * @since 2021-11-08
 */
@RestController
@RequestMapping("/erp/barcode/rule")
@Api(tags = "条码规则")
public class ErpBarcodeRuleController extends BaseController {


    @Autowired
    private IErpBarcodeRuleService barcodeRuleService;

    @PostMapping("save")
    @ApiOperation("保存 条码规则")
    public HttpResult save(@RequestBody ErpBarcodeRule erpBarcodeRule){
        Long id = barcodeRuleService.saveRule(erpBarcodeRule);
        return HttpResult.ok(id);
    }


    @GetMapping("page")
    @ApiOperation("分页查询 条码规则")
    public HttpResult save(Page page, ErpBarcodeRuleSearchMoreDto ruleSearchDto){
        return HttpResult.ok(barcodeRuleService.pageByBarcodeBo(page, ruleSearchDto));
    }


    @DeleteMapping("deleteByIds")
    @ApiOperation("批量删除 条码规则")
    public HttpResult deleteByIds(@RequestBody Long ...ids){
        barcodeRuleService.deleteByIds(ids);
        return HttpResult.ok();
    }

    @GetMapping("examine")
    @ApiOperation("审核/反审核 条码规则")
    public HttpResult examine(Long id,Integer status){
        barcodeRuleService.examine(id, status);
        return HttpResult.ok();
    }

    @GetMapping("detailById")
    @ApiOperation("查询详情")
    public HttpResult detailById(Long id){
        return HttpResult.ok(barcodeRuleService.detailById(id,true));
    }


}
